How to use JS SDK bridge token between Ethereum and Manta
Bridge ETH/ERC20 Between L1 and L2
Repo Link: bridge-between-l1-l2
Install
yarn
Setting Account
Prepare an account private key on L1 Sepolia and need some ETH
// open .env file
PRIVATE_KEY=YOUR_PRIVATE_KEY
Choose Network
// mainnet
const networkConfig = config.mainnet;
// sepolia testnet
const networkConfig = config.sepoliaTestnet;
Bridge ETH from L1 to L2
await depositETH();
Bridge ERC20 Token from L1 to L2
// need to fill in the corresponding token address and decimals first
const erc20Token = {
l1Address: "",
l2Address: "",
decimals: 18,
};
await depositERC20();
Bridge ETH/ERC20 from L2 to L1
Initiate Withdrawal
// withdraw ETH
const withdrawTxhash = await withdrawETH();
// withdraw ERC20 token const withdrawTxhash = await withdrawERC20();
2. Wait for 45 minutes
3. Prove Withdrawal
```typescript
await proveWithdrawMessage(withdrawTxhash);
Wait for 3 days (Testnet: one minute)
Claim Withdrawal
await finalizeWithdrawMessage(withdrawTxhash);
Bridge History
- Check history and status on SocialScan
- Check history and status via SocialScan's API
Withdraw Status
export enum WithdrawStatus {
WAIT_TO_PROVE = 1,
READY_TO_PROVE = 2,
IN_CHALLENGE_PERIOD = 3,
READY_FOR_RELAY = 4,
RELAYED = 5,
}